package com.example.second.service;

import com.example.second.dao.IStorageDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class StorageServiceImpl implements IStorageService{

    @Autowired
    private IStorageDao iStorageDao;

    public  Map<String,Object> insertStorge(String sku_id, double in_quanty, double out_quanty){
        Map<String,Object> resultMap = new HashMap<String, Object>();

        if(sku_id==""||sku_id==null){
            resultMap.put("result", false);
            resultMap.put("msg", "传入商品为空");
            return resultMap;
        }

        if(in_quanty==0.0&&out_quanty==0.0){
            resultMap.put("result", false);
            resultMap.put("msg", "商品数量未变");
            return resultMap;
        }

        return iStorageDao.insertStorage(sku_id, in_quanty, out_quanty);
    }

    public  Map<String,Object> updateOrderStatus(String order_id){
        HashMap<String,Object>  resultMap = new HashMap<String, Object>();
        if(iStorageDao.updateOrderStatus(order_id)){
            resultMap.put("result", true);
            resultMap.put("msg", "更新订单状态成功");
            return resultMap;
        }else {
            resultMap.put("result", false);
            resultMap.put("msg", "更新订单状态失败");
            return resultMap;
        }
    }
}
